package com.zx.练习题.icode.tdd;


import java.util.List;

public class Tdd {

    /**
     * 前进
     */
    public static final String f = "f";
    /**
     * 后退
     */
    public static final String b = "b";
    /**
     * 左转
     */
    public static final String l = "l";
    /**
     * 右转
     */
    public static final String r = "r";

    private Che che;

    private QuYu quYu;

    public void initChe(int x, int y, int fangxiang) {
        this.che = new Che();
        this.che.setX(x);
        this.che.setY(y);
        this.che.setFangxiang(fangxiang);
    }

    public void initQuYu(int x, int y) {
        if (che == null) {
            throw new TddException("车没有初始化");
        }
        if (!is(x, y)) {
            throw new TddException("位置超出探索区域");
        }
        this.quYu = new QuYu();
        this.quYu.setX(x);
        this.quYu.setY(y);
    }

    public Che go(List<String> commands) {
        if (che == null) {
            throw new TddException("车没有初始化");
        }
        if (quYu == null) {
            throw new TddException("区域没有初始化");
        }

        return che;
    }

    private boolean is(int x, int y) {
        return (x <= quYu.getX() && x >= 0) && (y <= quYu.getY() && y >= 0);
    }

}
